/*
 * @Author: 六弦(melodyWxy)
 * @Date: 2022-03-01 09:13:26
 * @LastEditors: 六弦(melodyWxy)
 * @LastEditTime: 2022-03-01 15:13:23
 * @FilePath: /menorepo-demo/Users/wxy/codeWorks/up/d_form/antd-demo-ts/src/components/XForm/type.tsx
 * @Description: update here
 */

import { ColProps, } from "antd";
import { Store } from "antd/lib/form/interface";



export enum FormSets{
    Form = "Form"
}

export enum FormItemSets{
    Item = "Item"
}


export interface FormProps {
    name?: string;
    labelCol?: ColProps;
    wrapperCol?: ColProps;
    autoComplete?: string;
    initialValues?: Store;
    [key: string]: any;
}

export interface FormItemProps{
    labelCol?: ColProps;
    wrapperCol?: ColProps;
    [key: string]: any;
}

export enum ChildTypeSets{
    Input = 'Input',
    InputNumber = 'InputNumber',
    Password = 'Password',
    Checkbox = 'Checkbox',
    Select = 'Select'
}

export const ChildOptions = [{
    label:  '输入框',
    value: ChildTypeSets.Input
},{
    label:  '数字输入框',
    value: ChildTypeSets.InputNumber
},{
    label:  '密码输入框',
    value: ChildTypeSets.Password
},{
    label:  '单选框',
    value: ChildTypeSets.Checkbox
},{
    label:  '下拉框',
    value: ChildTypeSets.Select
}]

export interface Child{
    type: ChildTypeSets,
    props?: Record<string ,any>
}

export interface FormItem{
    type: FormItemSets
    name: string,
    props: FormItemProps,
    required?: boolean,
    message?: string,
    child: Child
}


export interface Btn{
    wrapProps?: FormItemProps,
    type?: "link" | "text" | "ghost" | "primary" | "default" | "dashed",
    submit?: boolean,
    props?: Record<any,any>,
    text?: string
}


/**
 * @desc: 整体Schema的结构
 *  - @type: 表单的组件类型
 *  - @props: 表单组件的额外属性添加
 *  - @onFinish: submit按钮的回调
 *  - @children: 内部的表单项
 *  - @btns: 表单所有的按钮
 */
export interface FormSchema{
    type: FormSets,
    props: FormProps,
    onFinish: (value: any) => void,
    children: FormItem[],
    btns: Btn[],
    title?: string
}